﻿<UserControl x:Class="HouseKeepingPL.UserControls.Reports"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             Name="ReportsUserControl"
             d:DesignHeight="399"
             d:DesignWidth="738"
             DataContext="{Binding ReportVM,
                                   Source={StaticResource Locator}}"
             mc:Ignorable="d">


    <UserControl.Resources>
        <ControlTemplate x:Key="validationTemplate">
            <DockPanel>
                <Border BorderBrush="Red" BorderThickness="1">
                    <AdornedElementPlaceholder />
                </Border>
                <Border Width="20"
                        Height="20"
                        Margin="5,0,0,0"
                        Background="Red"
                        CornerRadius="10"
                        DockPanel.Dock="right"
                        ToolTip="{Binding ElementName=customAdorner,
                                          Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
                    <TextBlock HorizontalAlignment="center"
                               VerticalAlignment="center"
                               FontSize="20"
                               FontWeight="Bold"
                               Foreground="WhiteSmoke">
                        !!
                    </TextBlock>
                </Border>
            </DockPanel>
        </ControlTemplate>
        <Style x:Key="MyTabStyle" TargetType="Grid">
            <Setter Property="Background" Value="AliceBlue" />
        </Style>

        <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ComboBoxInError" TargetType="{x:Type ComboBox}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>

    </UserControl.Resources>



    <Grid Style="{StaticResource MyTabStyle}" UseLayoutRounding="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="1"
                    HorizontalAlignment="Center"
                    Orientation="Horizontal">
            <TextBlock Margin="5,5,5,5" Text="Report:" />
            <ComboBox Width="200"
                      Margin="0 5 5 0"
                      DisplayMemberPath="Description"
                      ItemsSource="{Binding Path=ReportTypes}"
                      SelectedValue="{Binding Path=CurrentlySelectedReportTypeId,
                                              Mode=TwoWay}"
                      SelectedValuePath="Id"
                      Text="Please Select Report" />
            <TextBlock Margin="15 5 15 0" Text="Date From:" />
            <DatePicker Grid.Row="0"
                        Grid.Column="1"
                        FirstDayOfWeek="Sunday"
                        Text="{Binding Path=DateFrom,
                                       ConverterCulture=he-IL,
                                       Mode=TwoWay}" />
            <TextBlock Margin="15 5 15 0" Text="Date To:" />
            <DatePicker Grid.Row="0"
                        Grid.Column="1"
                        FirstDayOfWeek="Sunday"
                        Text="{Binding Path=DateTo,
                                       ConverterCulture=he-IL,
                                       Mode=TwoWay}" />

        </StackPanel>


        <Border Width="5" />
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <TextBlock Width="180"
                       Margin="5"
                       VerticalAlignment="Center"
                       Text="{Binding Path=TotalReportText}" />
            <Grid MinWidth="500" MinHeight="921">
                <chartingToolkit:Chart Name="columnChart"
                                       Title="Reports"
                                       MinWidth="500"
                                       MinHeight="150"
                                       Margin="33,0,0,620"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Stretch">
                    <chartingToolkit:PieSeries DependentValuePath="Value"
                                               IndependentValuePath="Key"
                                               IsSelectionEnabled="True"
                                               ItemsSource="{Binding Path=ReportChartItems}" />
                </chartingToolkit:Chart>
            </Grid>
        </StackPanel>
    </Grid>

</UserControl>
